package com.mooke.dao.Impl;


import com.mooke.dao.AdminDao;
import com.mooke.entity.*;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class AdminDaoImpl extends SqlSessionDaoSupport implements AdminDao {



    @Autowired
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory)
    {
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    @Override
    public List<College> finAll(String id,  Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public boolean removeLoginStudent(String id,Map<String, Object> map){
        if(	getSqlSession().delete(id, map)>0)return true;
        return false;
    };


    public List<Teacher> findByNameTeacher(String id, Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public List<Teacher> findByPagingTeacher(String id,  Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public Integer getCountTeacher(String id, Map<String,Object> map){

        return getSqlSession().selectOne(id, map);
    };

    @Override
    public boolean checkTeacher(String id, Teacher teacher){
        if(	getSqlSession().selectOne(id, teacher)!=null) return true;
        return false;
    };

    @Override
    public boolean  addTeacher(String id, Teacher teacher){
        if(	getSqlSession().insert(id, teacher)>0)return true;
        return false;
    };

    @Override
    public boolean  addTeacherLogin(String id, Teacher teacher){
        if(	getSqlSession().insert(id, teacher)>0)return true;
        return false;
    };
    @Override
    public boolean  updateTeacher(String id, Teacher teacher){
        if(	getSqlSession().update(id, teacher)>0)return true;
        return false;
    };
    @Override
    public boolean removeTeacher(String id,Map<String, Object> map){
        if(	getSqlSession().delete(id, map)>0)return true;
        return false;
    };
    @Override
    public boolean queryMoneyleave(String id,Map<String, Object> map){
        if(	getSqlSession().selectList(id, map)!=null) {return true;}else{return false;}

    };
    @Override
    public boolean queryMoneyget(String id,Map<String, Object> map){
        if(	getSqlSession().selectList(id, map)!=null) {return true;}else{return false;}
    };

    @Override
    public List<Teacher> leave(String id, Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public List<Teacher> get(String id, Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public boolean  addWages(String id, Map<String,Object> map){
        if(	getSqlSession().insert(id, map)>0)return true;
        return false;
    };

    @Override
    public boolean checkcollegeID(String id, College college){
        if(	getSqlSession().selectOne(id, college)!=null) return true;
        return false;
    };

    @Override
    public boolean  addCollegeed(String id, College college){
        if(	getSqlSession().insert(id, college)>0)return true;
        return false;
    };

    @Override
    public boolean  updateCollege(String id, College college){
        if(	getSqlSession().update(id, college)>0)return true;
        return false;
    };

    @Override
    public List<Salary> findCheckinginByNameType(String id, Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    }
    @Override
    public List<Salary> findCheckinginByName(String id, Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    }
    @Override
    public List<Salary> findCheckinginByType(String id, Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    }

    @Override
    public boolean  addCheckingin(String id, Salary salary){
        if(	getSqlSession().insert(id, salary)>0)return true;
        return false;
    };
    @Override
    public boolean  editCheckingined(String id, Salary salary){
        if(	getSqlSession().update(id, salary)>0)return true;
        return false;
    };

    @Override
    public boolean  removeCheckingin(String id, Salary salary){
        if(	getSqlSession().delete(id, salary)>0)return true;
        return false;
    };

    @Override
    public List<Teacher> findByNameVacate(String id,  Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };
    @Override
    public List<Teacher> findByNameVacate1(String id,  Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public Integer getCountByNameVacate(String id, Map<String,Object> map){

        return getSqlSession().selectOne(id, map);
    };
    @Override
    public List<Teacher> findByPagingVacate(String id,  Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public Integer getCountVacate(String id, Map<String,Object> map){

        return getSqlSession().selectOne(id, map);
    };

    @Override
    public boolean  editVacate(String id, Teacher teacher){
        if(	getSqlSession().update(id, teacher)>0)return true;
        return false;
    };

    @Override
    public List<Teacher> findByNameBonus(String id,  Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public Integer getCountByNameBonus(String id, Map<String,Object> map){

        return getSqlSession().selectOne(id, map);
    };
    @Override
    public List<Teacher> findByPagingBonus(String id,  Map<String,Object> map){
        return getSqlSession().selectList(id, map);
    };

    @Override
    public Integer getCountBonus(String id, Map<String,Object> map){

        return getSqlSession().selectOne(id, map);
    };

    @Override
    public boolean addBonused (String id, Teacher teacher){
        if(	getSqlSession().insert(id, teacher)>0)return true;
        return false;
    };

    @Override
    public boolean  editBonused(String id, Teacher teacher){
        if(	getSqlSession().update(id, teacher)>0)return true;
        return false;
    };

    @Override
    public Integer getCountMoneyleave(String id, Map<String,Object> map){

        return getSqlSession().selectOne(id, map);
    };
    @Override
    public Integer getCountMoneyget(String id, Map<String,Object> map){

        return getSqlSession().selectOne(id, map);
    };
    @Override
    public Integer getCountMoney(String id, Map<String,Object> map){

        return getSqlSession().selectOne(id, map);
    };
    @Override
    public String getState(String id, Map<String,Object> map){
        return getSqlSession().selectOne(id, map);
    };

    @Override
    public boolean  updateContract(String id, Teacher teacher){
        if(	getSqlSession().update(id, teacher)>0)return true;
        return false;
    };


}
